package haw.pr2.A3.implementations;

import haw.pr2.A3.interfaces.*;
import java.util.Collection;
import java.util.Set;
import static haw.pr2.A3.implementations.UtilityclassValues.*;
import haw.pr2.A3.interfaces.Container;

/**
 *
 * @author Fabian Heidorn, Alexander Kaack
 */
abstract class AbstractContainer implements Container {
    
    UniqueId id =UniqueIdImpl.getNextID();
    StowageLocation loc;
    Stowage myStowage;
    Stowage pallets;
    Mass emptyMass;
    Mass maxMass;
    BoundingBox bBox;

    @Override
    public Mass mass() {
        return pallets.mass().add(emptyMass);
    }

    @Override
    public BoundingBox boundingBox() {
        return this.bBox;
    }

    @Override
    public Mass emptyMass() {
        return this.emptyMass;
    }

    @Override
    public Mass maxMass() {
        return this.maxMass;
    }

    @Override
    public void load(int bayNo, int rowNo, Pallet elem) {
        pallets.load(bayNo, rowNo, elem);
    }

    @Override
    public void load(Pallet elem) {
        pallets.load(elem);
    }

    @Override
    public void loadAll(Collection<Pallet> coll) {
        pallets.loadAll(coll);
    }

    @Override
    public boolean tierIsEmpty(int bay, int row) {
        return pallets.tierIsEmpty(bay, row);
    }

    @Override
    public boolean tierIsFull(int bay, int row) {
        return pallets.tierIsFull(bay, row);
    }

    @Override
    public boolean contains(Object elem) {
        return pallets.contains(elem);
    }

    @Override
    public boolean containsAll(Collection<?> coll) {
        return pallets.containsAll(coll);
    }

    @Override
    public int compareTo(Container c) {
        return this.UniqueId().compareTo(c.UniqueId());
    }

    @Override
    public Location loc() {
        return this.loc;
    }

    @Override
    public void setLocNull() {
        this.loc = nullLocation();
    }

    @Override
    public void setLoc(Stowage stowage, StowageLocation loc) {
        this.loc=loc;
        this.myStowage=stowage;
    }

    @Override
    public Pallet get(StowageLocation loc) {
        return (Pallet) this.pallets.get(loc);
    }

    @Override
    public Set<Pallet> getAll() {
        return this.pallets.getAll();
    }

    @Override
    public StowageLocation locationOf(Pallet elem) {
        return this.pallets.locationOf(elem);
    }

    @Override
    public UniqueId UniqueId() {
        return this.id;
    }
    
    @Override
    public boolean equals(Object obj) {
        if (obj == this) return true;
        if (!(obj instanceof Container)) return false;
        return this.compareTo((Container)obj) == 0;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 59 * hash + (this.id != null ? this.id.hashCode() : 0);
        return hash;
    }

   
}
